<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>class</title>
</head>
<body>
<script>
    /*
    class 是构造函数的语法糖
* */

    // 普通写法
    function Car(name) {
        this.name = name //第2个找
    }
    Car.prototype.run = function () {
        console.log( this.name + '跑起来')
    }
    // Card的静态方法
    Car.isCar = function (t){
        console.log(t)
    }
    var car = new Car('小黄车');
    Car.isCar('Car的静态方法')
    car.run()


    //class写法
    class Ccar {
        #a = 0defineProperty
        constructor(name) {
            this.name = name //第2个找
        }
        run(){
            console.log( this.name + '跑起来')
        }
        static isCar(t){ //说明这是一个静态方法
            console.log(t)
        }
        get a (){
            return this.#a
        }
        set a(val) {
            this.#a = 6
        }
    }
    var ccar = new Ccar('小蓝车');
    Ccar.isCar('Ccar的静态方法')
    ccar.run()
</script>
</body>
</html>
